{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "06e197f5",
   "metadata": {},
   "source": [
    "* 日期：2022.11.23\n",
    "* 记录人：liyuanyuan"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f6834f7",
   "metadata": {},
   "source": [
    "# 1.函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b13c54f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user():\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9377d8b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "greet_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "327a116f",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user(username):\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello\",username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "886555d5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello 李华\n"
     ]
    }
   ],
   "source": [
    "greet_user(username=\"李华\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "ec12c2df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "18\n"
     ]
    }
   ],
   "source": [
    "def f(x):\n",
    "    \"\"\"y=2x的函数计算\"\"\"\n",
    "    print(2*x)\n",
    "f(9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f17612c4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数的意义 1：重复使用\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "33612010",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践：广州南方学院新闻网站url实践函数\n",
    "def NFU_NEWS_URL(分类,页码): \n",
    "    \"\"\"广州南方学院新闻页面URL数据\n",
    "       分类只需要写对应的编码就可以，对应的页码如下\n",
    "       分类包含：【学校要闻:xxyw,校园动态:xydt,通知公告:tzgg,招投标:ztd】\n",
    "       页码包含:【113,106,37,27】\n",
    "    \"\"\"\n",
    "    for i in range(页码):\n",
    "        print(\"https://www.nfu.edu.cn/\" + 分类 + \"/index\" + str(i) + \".htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "82e36628",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/tzgg/index0.htm\n",
      "https://www.nfu.edu.cn/tzgg/index1.htm\n",
      "https://www.nfu.edu.cn/tzgg/index2.htm\n",
      "https://www.nfu.edu.cn/tzgg/index3.htm\n",
      "https://www.nfu.edu.cn/tzgg/index4.htm\n",
      "https://www.nfu.edu.cn/tzgg/index5.htm\n",
      "https://www.nfu.edu.cn/tzgg/index6.htm\n",
      "https://www.nfu.edu.cn/tzgg/index7.htm\n",
      "https://www.nfu.edu.cn/tzgg/index8.htm\n",
      "https://www.nfu.edu.cn/tzgg/index9.htm\n",
      "https://www.nfu.edu.cn/tzgg/index10.htm\n",
      "https://www.nfu.edu.cn/tzgg/index11.htm\n",
      "https://www.nfu.edu.cn/tzgg/index12.htm\n",
      "https://www.nfu.edu.cn/tzgg/index13.htm\n",
      "https://www.nfu.edu.cn/tzgg/index14.htm\n"
     ]
    }
   ],
   "source": [
    "NFU_NEWS_URL(\"tzgg\",15)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "a4ff45b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module __main__:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    广州南方学院新闻页面URL数据\n",
      "    分类只需要写对应的编码就可以，对应的页码如下\n",
      "    分类包含：【学校要闻:xxyw,校园动态:xydt,通知公告:tzgg,招投标:ztd】\n",
      "    页码包含:【113,106,37,27】\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce17eae6",
   "metadata": {},
   "source": [
    "# 2.模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "ebeab953",
   "metadata": {},
   "outputs": [],
   "source": [
    "import college_url_crawl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "6b8a7b7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module college_url_crawl:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    广州南方学院新闻页面URL数据\n",
      "    分类只需要写对应的编码就可以，对应的页码如下\n",
      "    分类包含：【学校要闻:xxyw,校园动态:xydt,通知公告:tzgg,招投标:ztd】\n",
      "    页码包含:【113,106,37,27】\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(college_url_crawl.NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "66beb8a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/tzgg/index0.htm\n",
      "https://www.nfu.edu.cn/tzgg/index1.htm\n",
      "https://www.nfu.edu.cn/tzgg/index2.htm\n",
      "https://www.nfu.edu.cn/tzgg/index3.htm\n",
      "https://www.nfu.edu.cn/tzgg/index4.htm\n",
      "https://www.nfu.edu.cn/tzgg/index5.htm\n",
      "https://www.nfu.edu.cn/tzgg/index6.htm\n",
      "https://www.nfu.edu.cn/tzgg/index7.htm\n",
      "https://www.nfu.edu.cn/tzgg/index8.htm\n",
      "https://www.nfu.edu.cn/tzgg/index9.htm\n",
      "https://www.nfu.edu.cn/tzgg/index10.htm\n",
      "https://www.nfu.edu.cn/tzgg/index11.htm\n",
      "https://www.nfu.edu.cn/tzgg/index12.htm\n",
      "https://www.nfu.edu.cn/tzgg/index13.htm\n",
      "https://www.nfu.edu.cn/tzgg/index14.htm\n"
     ]
    }
   ],
   "source": [
    "college_url_crawl.NFU_NEWS_URL(\"tzgg\",15)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
